/**
 * Created by dukes on 2015/12/22.
 */
//module game{
    class ScoreItemRender extends eui.ItemRenderer{
        public constructor(){
            super();
            this.skinName = "pet.ScoreItemRenderSkin";
        }

        private onGet(evt:egret.TouchEvent){
            window["__vipScore"](this.data.type);
        }

        public lab_title:eui.Label;
        public lab_pro:eui.Label;
        public img_get:eui.Image;
        public lab_score:eui.Label;
        public partAdded(name:string, instance:any) {
            super.partAdded(name, instance);
            if (name == "lab_title") {
                this.lab_title = instance;
            } else if (name == "lab_pro") {
                this.lab_pro = instance;
            } else if (name == "img_get") {
                this.img_get = instance;
                this.img_get.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onGet, this);
            }else if( name == "lab_score"){
                this.lab_score = instance;
            }
        }

        public dataChanged(){
            super.dataChanged();
            /**
             * TYPE_每日登陆 = 1;
             * TYPE_连续登陆 = 2;
             * TYPE_掠夺获胜 = 3;
             * STATUS_未达成 = 0;
             * STATUS_已达成 = 1;
             * STATUS_已领取 = 2;
             **/
            //var arr = [{type:1,status:info.dailyLoginStatus},{type:2,status:info.successionLoginStatus},{type:3,status:info.pillageWinStatus}];
            if(this.data.status == 0){
                this.lab_pro.visible = true;
                this.img_get.visible = false;
            }else if(this.data.status == 1){
                this.lab_pro.visible = false;
                this.img_get.visible = true;
                this.img_get.touchEnabled = true;
                this.img_get.source = RES.getRes("img_get");
            }else if(this.data.status == 2){
                this.lab_pro.visible = false;
                this.img_get.visible = true;
                this.img_get.touchEnabled = false;
                this.img_get.source = RES.getRes("img_complete");
            }
            var config = ActivityMgr.getInstance().getActivityConfigById(ActivityMgr.ACTIVITY_VIP_SCORE).config[0];
            if(this.data.type == 1){
                this.lab_title.text = "每天登陆一次";
                this.lab_score.text ="+"+config.dailyLoginScore;
            }else if(this.data.type == 2){
                this.lab_title.text = "连续登陆";
                this.lab_score.text ="+"+config.successionScore;
            }else if(this.data.type == 3){
                this.lab_title.text = "每天战斗胜利一次";
                this.lab_score.text ="+"+config.pillageWinScore;
            }
        }
    }
//}